﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using System.Web;
using System.Configuration;
using Microsoft.Practices.Unity.Configuration;

namespace Base.Core.UnityFactory
{
    public static class IOCFactory
    {

        public static T GetIOCResolve<T>()
        {
            if (HttpContext.Current.Application["UnityContainer"] != null && HttpContext.Current.Application["UnityContainer"] != "")
            {
                IUnityContainer ioc = HttpContext.Current.Application["UnityContainer"] as UnityContainer;
                return ioc.Resolve<T>();

            }
            else
            {
                throw new Exception("IOC容器初始化发生错误!");
            }
        }
    }
}
